package cn.sylinx.horm.example.section12;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorString;

public class FormatDateFunction extends AbstractFunction {

    @Override
    public String getName() {
        return "format_current_date";
    }

    @Override
    public AviatorObject call(Map<String, Object> env) {
        Date d = new Date();
        String formateDateStr = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(d);
        return new AviatorString(formateDateStr);
    }

}
